//
//  KTDefines.h
//  KoreaTV
//
//  Created by renren  on 2022/11/20.
//

#ifndef KTDefines_h
#define KTDefines_h

#define screen_width [UIScreen mainScreen].bounds.size.width
#define screen_height [UIScreen mainScreen].bounds.size.height


// 尺寸计算
// 判断iPhoneX
#define iphoneX \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})


#define WIDTH_PRO(X)  ((iphoneX == 1) ? (X) * (screen_width / 812) : (X) * (screen_width/667))
#define HEIGHT_PRO(Y) ((iphoneX == 1) ? (Y) * (screen_height / 375) : (Y) * (screen_height/375))

#define Width_375 (WIDTH_PRO(375))
#define Height_667 (HEIGHT_PRO(667))


#define ktTabBarH 49
#define ktNavigationBarH 44

#pragma mark - 常用系统方法
///key_window
#define key_window [UIApplication sharedApplication].windows.firstObject
/// 是否为刘海屏系列
#define isiPhoneXLater [NSObject is_iPhoneXSerial]
/// 状态栏高度
#define status_height [UIApplication sharedApplication].keyWindow.safeAreaInsets.top
/// 底部高度
#define bottom_height [UIApplication sharedApplication].keyWindow.safeAreaInsets.bottom
/// 顶部安全高度
#define top_safeArea [UIApplication sharedApplication].keyWindow.safeAreaInsets.top + 44

//字体  ====================
#define SYS_Font(a) [UIFont systemFontOfSize:(a)]

#define fontThin(sizeThin) [UIFont fontWithName:@"HelveticaNeue-Thin" size:(sizeThin)]
#define fontMT(sizeThin)   [UIFont fontWithName:@"Arial-ItalicMT" size:(sizeThin)]

#define FONT [UIFont systemFontOfSize:16];

//PingFangSC-Medium字体
#define PingFangSC_Medium(a) [UIFont fontWithName:@"PingFangSC-Medium" size:a]
#define PingFangSC_Regular(a) [UIFont fontWithName:@"PingFangSC-Regular" size:a]

#define PingFangSC_Bold(a) [UIFont fontWithName:@"PingFangSC-Semibold" size:a]

#pragma mark - 字体样式&大小
/// 设置系统类型的字体
#define kFontSystem(fsize) [UIFont systemFontOfSize:fsize]
/// 设置Media类型的字体
#define kFontMedia(msize) [UIFont systemFontOfSize:msize weight:UIFontWeightMedium];
/// 设置bold类型的字体
#define kFontBold(size) [UIFont boldSystemFontOfSize:size]
#define kFontSizeLarge 16
#define kFontSizeMid 14
#define kFontSizeSmall 12

///图片获取
#define kGetImage(imageName) [UIImage imageNamed:imageName]
#define kPlaceHolder [UIImage imageNamed:@"img_userinfo_bg"]
#pragma mark - 弹窗
///弹窗样式一
#define kAlertShowVC(titleText,messageText,buttonName)\
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:(titleText) message:(messageText) preferredStyle:UIAlertControllerStyleAlert];\
[alertVC addAction: [UIAlertAction actionWithTitle:(buttonName) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {\
}]];\
[key_window.rootViewController presentViewController:alertVC animated:YES completion:nil];\
/// 弹窗样式二
#define kAlertShow(titleText,messageText,buttonName1,buttonName2,SEL1,SEL2)\
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:(titleText) message:(messageText) preferredStyle:UIAlertControllerStyleAlert];\
[alertVC addAction: [UIAlertAction actionWithTitle:(buttonName1) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {SEL1;}]];\
[alertVC addAction: [UIAlertAction actionWithTitle:(buttonName2) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {SEL2;}]];\
[self presentViewController:alertVC animated:YES completion:nil];\


#pragma mark - 颜色相关
/// RGB颜色
#define kRGB(r, g, b)             [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:1.0]
/// RGBA颜色
#define kRGBAlpha(r, g, b, a)     [UIColor colorWithRed:((r) / 255.0) green:((g) / 255.0) blue:((b) / 255.0) alpha:(a)]
/// 哈希颜色值
#define kColor(hexString) [UIColor colorWithHexString:hexString]

#define kGrayColor  kColor(@"#999999")
#define kThemeColor kColor(@"#0940EC")
#define kLoginColor kColor(@"#323FEE")

#define kBlack  kColor(@"#000000")
#define k9B9B9B  kColor(@"#9B9B9B")
#define k262628 kColor(@"#262628")
#define k666666 kColor(@"#666666")
#define kF5F5F5 kColor(@"#F5F5F5")
#define kF2F5FA kColor(@"#F2F5FA")
#define k333333 kColor(@"#333333")
#define k1stColor kColor(@"#E02020")
#define k2ndColor kColor(@"#F7B500")
#define k3rdColor kColor(@"#6DD400")


#define kLoginTokenKey @"kLoginTokenKey"
#define kUserAccountKey @"kUserAccountKey"
#define kUserIconKey @"kUserIconKey"
#define kUserIDKey @"kUserIDKey"
#define kUserVIPKey @"kUserVIPKey"
///应用版本
#define KTAppversion [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"]




//#ifndef weakify
//    #if DEBUG
//        #if __has_feature(objc_arc)
//            #define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
//        #else
//            #define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
//        #endif
//    #else
//        #if __has_feature(objc_arc)
//            #define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
//        #else
//            #define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
//        #endif
//    #endif
//#endif
//
//
//#ifndef strongify
//    #if DEBUG
//        #if __has_feature(objc_arc)
//            #define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
//        #else
//            #define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
//        #endif
//    #else
//        #if __has_feature(objc_arc)
//            #define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
//        #else
//            #define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
//        #endif
//    #endif
//#endif

#ifdef DEBUG
#define HWLog(format, ...) printf("[%s] %s [第%d行] %s\n", [[HWToolBox currentTimeCorrectToMillisecond] UTF8String], __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else
#define HWLog(format, ...)
#endif


#endif /* KTDefines_h */
